﻿using System;
using System.Collections.ObjectModel;

namespace WgpgCore
{
    public static class Extensions
    {
        public static Boolean Exists<T>(this ObservableCollection<T> list, Predicate<T> predicate) where T : class
        {
            return list.Find(predicate) != null;
        }

        public static T Find<T>(this ObservableCollection<T> list, Predicate<T> predicate) where T : class
        {
            foreach (T item in list)
                if (predicate(item))
                    return item;
            return default(T);
        }
    }
}
